//
//  UIBarButtonItem+Extensions.swift
//  YYLWeibo
//
//  Created by 楊亜玲 on 16/11/10.
//  Copyright © 2016年 楊亜玲. All rights reserved.
//

import Foundation

extension UIBarButtonItem {
    convenience init(title: String,fontSize: CGFloat = 16, target: AnyObject?, action: Selector, isBackButton: Bool = false) {
        let btn: UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        if isBackButton {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
            
            btn.sizeToFit()
        }

        
        // 实例化 UIBarButtonItem
        self.init(customView: btn)

    }
}
